package com.yanqu.road.server.cmd.banquet.party;

import com.alibaba.fastjson.JSON;
import com.yanqu.road.entity.banquet.BanquetInfo;
import com.yanqu.road.entity.banquet.UserBanquetSetting;
import com.yanqu.road.entity.banquet.invitation.BanquetMarryInvitation;
import com.yanqu.road.entity.enums.eBanquetInfoType;
import com.yanqu.road.entity.enums.eSystemId;
import com.yanqu.road.entity.player.UserBeauty;
import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.banquet.BanquetProto;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.banquet.BanquetModule;
import com.yanqu.road.server.gameplayer.module.player.BeautyModule;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.gameplayer.module.player.PreReduceModule;
import com.yanqu.road.server.manger.CrossMarriageGroupMgr;
import com.yanqu.road.server.manger.VipMgr;
import com.yanqu.road.server.manger.banquet.BanquetConfigMgr;
import com.yanqu.road.server.manger.config.SystemOpenMgr;
import com.yanqu.road.server.manger.player.UserMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.property.PropertyHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.util.List;

//@Cmd(code = GameProtocol.S_PARTY_OPEN, desc = "")
@Cmd(code = Protocol.S_BANQUET_USER_SETTING_GET, desc = "获得宴会设置数据")
public class GetBanquetSettingCmd extends AbstractCommand {
    private int type;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        BanquetProto.GetBanquetSettingReqMsg reqMsg = BanquetProto.GetBanquetSettingReqMsg.parseFrom(packet.getBytes());
        this.type = reqMsg.getType();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        if (BanquetConfigMgr.isServerNormalBanquet(type) && !SystemOpenMgr.systemOpen(player, eSystemId.Banquet.getValue())) {
            ret = GameErrorCode.E_SYSTEM_NO_OPEN;
            return;
        }
        if (BanquetConfigMgr.isServerFeastBanquet(type) && !SystemOpenMgr.systemOpen(player, eSystemId.BanquetServer.getValue())) {
            ret = GameErrorCode.E_SYSTEM_NO_OPEN;
            return;
        }
        BanquetModule banquetModule = player.getModule(BanquetModule.class);
        BanquetInfo banquetInfo = BanquetConfigMgr.getBanquetInfo(type);
        if (banquetInfo == null) {
            ret = GameErrorCode.E_BANQUET_INFO_ERROR;
            return;
        }
        String giftTypeAccept = banquetModule.getUserBanquetSettingGiftTypeAccept(type);
        BanquetProto.GetBanquetSettingRespMsg.Builder respMsg = BanquetProto.GetBanquetSettingRespMsg.newBuilder();
        respMsg.setType(type);
        respMsg.setGiftTypeAccept(giftTypeAccept);

        player.sendPacket(ClientProtocol.U_BANQUET_USER_SETTING_GET, respMsg);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
